/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 *
 */
import { BaseEvent, EventAdditional, EventBody, EventHead, MetricEventType } from './base-event.js';

export class CounterEventAdditional implements EventAdditional {
  success: number;
  failed: number;

  constructor(success?: number, failed?: number) {
    this.success = success ?? 0;
    this.failed = failed ?? 0;
  }
}

export class CounterEvent extends BaseEvent {
  additional: CounterEventAdditional;

  constructor(id: string, name: string, description: string, pid: number, tid: string, success?: number, failed?: number) {
    super(new EventHead(id, name, description, MetricEventType.COUNTER), new EventBody(pid, tid));
    this.additional = new CounterEventAdditional(success, failed);
    this.body.startTime = Number(process.hrtime.bigint());
  }
}
